package GUI.Panels.GameObjectPanels.ShipPanels;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionListener;

import javax.swing.JPanel;
import javax.swing.JTextArea;

import GUI.BottomPanel;
import GUI.GameScreen;
import GUI.Panels.GameObjectPanels.ObjectPanel;
import GUI.Panels.GameObjectPanels.ReactorPanel;
import GUI.Panels.GameObjectPanels.SheildPanel;
import GUI.Panels.GameObjectPanels.WeaponPanel;

public class ShipPanel extends ObjectPanel 
{
	private static final int BUFFER = 10;
	
	private static final int MINI_MAP_WIDTH = BottomPanel.WIDTH/4 - BUFFER;
	private static final int MINI_MAP_HEIGHT = BottomPanel.HEIGHT - BUFFER*4;

	private static final int SHIP_INFO_WIDTH = BottomPanel.WIDTH/2 - BUFFER;
	private static final int SHIP_INFO_HEIGHT = BottomPanel.HEIGHT - BUFFER*4;
	
	public static final int REACTOR_WIDTH = BottomPanel.WIDTH/4 - BUFFER;
	public static final int REACTOR_HEIGHT = BottomPanel.HEIGHT - BUFFER*4;
	
	public static final int SHEILD_WIDTH = BottomPanel.WIDTH/4 - BUFFER;
	public static final int SHEILD_HEIGHT = BottomPanel.HEIGHT - BUFFER*4;
	
	private final JTextArea txt = new JTextArea();
	
	private final JPanel panel;
	
	private ReactorPanel reactorPanel;
	private SheildPanel sheildPanel;
	private WeaponPanel weaponPanel;
	private static final long serialVersionUID = 1L;
	
	public ShipPanel(ActionListener actionListener, double health, double sheildEnergy, double engineEnergy)
	{
		panel = new JPanel(new BorderLayout());
		panel.setSize(new Dimension(BottomPanel.WIDTH, BottomPanel.HEIGHT));
		panel.setBackground(Color.RED);
		
		this.reactorPanel = new ReactorPanel(actionListener);
		this.sheildPanel = new SheildPanel(actionListener, sheildEnergy);
		
		this.txt.setSize(new Dimension(SHIP_INFO_WIDTH, SHIP_INFO_HEIGHT));
		this.txt.setLineWrap(true);
		this.txt.setEditable(false);
		this.txt.setText("Health: "+health+"\nEngine: "+engineEnergy);
		
		panel.add(txt, BorderLayout.CENTER);
		panel.add(this.sheildPanel, BorderLayout.EAST);
		panel.add(this.reactorPanel, BorderLayout.WEST);
		
		add(panel);
	}
	
	public void update(double health, double sheildEnergy, double engineEnergy)
	{
		this.txt.setText("Health: "+health+"\nEngine: "+engineEnergy);
		this.sheildPanel.update(sheildEnergy);
		this.reactorPanel.update();
	}
}
